/*
 * selectionSort.h
 *
 *  Created on: 28-nov.-2013
 *      Author: Axel
 */

#ifndef SELECTIONSORT_H_
#define SELECTIONSORT_H_

template<class T>
void selectionSort(T* list) {
	T table = (*list);
	int index = 0;
	int min = 0;
	int hulp;
	while (index < table.length() - 1) {
		min = kleinsteElem(table, index);
		hulp = table[index];
		table[index] = table[min];
		table[min] = hulp;
		index ++;
	}
}

template<class T>
int kleinsteElem(T tabel, int indx) {
	int min = tabel[indx];
	int minindex = indx;
	int index = indx;
	while (index < tabel.length()){
		if (tabel[index] < min) {
			minindex = index;
			min = tabel[index];
		}
		index++;
	}
	return minindex;
}

#endif /* SELECTIONSORT_H_ */
